package cn.study.springsecurityoauth2.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName PermisssionController
 * @Author swj
 * @Date 2020/10/15 13:53
 */
@RestController
@RequestMapping("per")
public class PermisssionController {
    private Logger logger = LoggerFactory.getLogger(PermisssionController.class);

    @GetMapping
    @PreAuthorize("hasPermission('user','') or hasRole('admin')" )
    public String get(){
        logger.info("访问成功");
        return "success";
    }
}
